package com.webside.Advertisingstatistics.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webside.Advertisingstatistics.mapper.AdSingleStatMapper;
import com.webside.Advertisingstatistics.model.AdSingleStatEntity;
import com.webside.Advertisingstatistics.service.AdSingLeStatService;
import com.webside.Advertisingstatistics.service.AdbrowerRecordsService;
import com.webside.base.baseservice.impl.AbstractService;
import com.webside.resource.model.ResourceEntity;
/***
 * lpz 广告单个广告记录信息
 * @author Administrator
 *
 */
@Service("AdSingLeStatService")
public class AdSingLeStatServiceImpl extends AbstractService<ResourceEntity, Long> implements AdSingLeStatService {
	@Autowired
	private AdSingleStatMapper adSingLeStatMapper;
	@Autowired
	private AdbrowerRecordsService adbrowerRecordsService;
	
	// 这句必须要加上。不然会报空指针异常，因为在实际调用的时候不是BaseMapper调用，而是具体的mapper，这里为userMapper

	@Autowired
	public void setBaseMapper() {
		super.setBaseMapper(adSingLeStatMapper);
	}
	//// 在每日00:01分的时候将昨日的每个广告的数据统计出来并存入mysql中
	@Override
	public int addAdSingleStat() {
		// TODO Auto-generated method stub\
		//获取所有的广告的统计信息
		List<AdSingleStatEntity> adSingleStatList = adbrowerRecordsService.AdSingleStatList();
		int i=0;
		if(null != adSingleStatList){
			for(AdSingleStatEntity ase:adSingleStatList){
				i = adSingLeStatMapper.addAdSingleStat(ase);
			}
			
		}
		
		return i;
	}
	// 在每日00：01统计数据之前先删除历史数据
	@Override
	public int deleteAdSingleStat() {
		// TODO Auto-generated method stub
		return adSingLeStatMapper.deleteAdSingleStat();
	}
	
	//根据广告名查询信息
	@Override
	public AdSingleStatEntity selectAdSingleStat(String adTitle) {
		// TODO Auto-generated method stub
		return adSingLeStatMapper.selectAdSingleStat(adTitle);
	}

}
